Skip to content

Improved version matching in lib and core commands. #2110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 16, 2023

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Mar 14, 2023

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

The version comparison in lib commands has been improved so 1.0, 1.0.0, and even 1 can be used to install a library.

What is the current behavior?

Sometimes there are discrepancies from the command output and the accepted command input, as described in detail in #1727.

$ ./arduino-cli lib install [email protected]
Downloading [email protected]...
Installing [email protected]...
Installed [email protected]
$ ./arduino-cli lib list --format json                      
[
  {
    "library": {
      "name": "ILI9341_t3",
      "author": "Limor Fried, Adafruit, Paul Stoffregen",
      "maintainer": "Paul Stoffregen",
      "sentence": "Optimized ILI9341 (320x240 Color TFT) Display",
      "website": "https://github.com/PaulStoffregen/ILI9341_t3",
      "category": "Display",
      "architectures": [
        "*"
      ],
      "install_dir": "/Users/a.kitta/Documents/Arduino/libraries/ILI9341_t3",
      "source_dir": "/Users/a.kitta/Documents/Arduino/libraries/ILI9341_t3",
      "real_name": "ILI9341_t3",
      "version": "1.0",              <----- listed as "1.0"
      "license": "Unspecified",
      "location": 1,
      "provides_includes": [
        "ILI9341_t3.h"
      ]
    }
  }
]
$ ./arduino-cli lib install "ILI9341_t3"@1.0               <--- did not accept "1.0"
Error installing ILI9341_t3: Library '[email protected]' not found

What is the new behavior?

$ ./arduino-cli lib install [email protected]
Already installed [email protected]

Does this PR introduce a breaking change, and is titled accordingly?

Hopefully no.

Other information

Fix #1727

Based on: bugst/relaxed-semver#12 (it must be merged before this one done!)

@cmaglie cmaglie self-assigned this Mar 14, 2023
@cmaglie cmaglie added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Mar 14, 2023
@codecov
Copy link

codecov bot commented Mar 14, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (2493b56) 35.10% compared to head (e3c7636) 35.11%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2110   +/-   ##
=======================================
  Coverage   35.10%   35.11%           
=======================================
  Files         232      232           
  Lines       20496    20494    -2     
=======================================
+ Hits         7196     7197    +1     
+ Misses      12453    12451    -2     
+ Partials      847      846    -1     
Flag Coverage Δ
unit 35.11% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
arduino/cores/cores.go 62.37% <100.00%> (ø)
arduino/cores/packagemanager/download.go 34.61% <100.00%> (ø)
arduino/cores/status.go 56.07% <100.00%> (ø)
arduino/cores/tools.go 88.46% <100.00%> (ø)
arduino/libraries/librariesindex/index.go 82.85% <100.00%> (-0.48%) ⬇️
arduino/libraries/librariesindex/json.go 100.00% <100.00%> (ø)
commands/lib/search.go 93.10% <100.00%> (ø)

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@cmaglie cmaglie force-pushed the normalize_versions branch from f97c2b5 to 0528360 Compare March 15, 2023 10:35
@cmaglie cmaglie force-pushed the normalize_versions branch from 0528360 to cc65e27 Compare March 15, 2023 10:38
@cmaglie cmaglie marked this pull request as ready for review March 15, 2023 11:12
@cmaglie cmaglie changed the title Improved version matching in lib commands. Improved version matching in lib and core commands. Mar 15, 2023
@cmaglie cmaglie merged commit d5eb0b7 into arduino:master Mar 16, 2023
@cmaglie cmaglie deleted the normalize_versions branch March 16, 2023 15:24
kittaakos pushed a commit to kittaakos/arduino-cli that referenced this pull request Mar 21, 2023
* Added test

* Use normalized version as keys for matching versions in maps

* Use normalized version as keys for matching versions in maps for platforms and tools

* Updated relaxed-semver to 0.10.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lib list/core list might list the library/platform versions in a non-semver compliant way
2 participants